﻿using System;
using System.Diagnostics;
using ProjScan.Config;
using ProjScan.ScanGUI.Tools;
using ProjScan.Tools;
using UnityEditor;
using UnityEngine;

namespace ProjScan.ScanGUI.Page
{
	// Token: 0x0200026C RID: 620
	internal class GeneralPage : BasePage<GlobalConfig>
	{
		// Token: 0x060010AF RID: 4271 RVA: 0x0004CDC8 File Offset: 0x0004AFC8
		public GeneralPage()
		{
			this.pageId = "General";
			this.pageName = "通用设置";
		}

		// Token: 0x060010B0 RID: 4272 RVA: 0x00008259 File Offset: 0x00006459
		public override void Init()
		{
			this.locationPath = ToolsHelper.GetFullPathByName("ProjScanConfig.json");
			this.projectScanConfigPath = ToolsHelper.GetLocationPath();
		}

		// Token: 0x060010B1 RID: 4273 RVA: 0x0004CE24 File Offset: 0x0004B024
		public override void OnGUI(Rect mainRectangle)
		{
			this.rect = mainRectangle;
			EditorGUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			EditorGUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("本地资源检测插件版本号：" + Singleton<ScanInfo>.Instance.version, Array.Empty<GUILayoutOption>());
			GUILayout.Space(20f);
			bool flag = GUILayout.Button("?", new GUILayoutOption[]
			{
				GUILayout.Width(20f),
				GUILayout.Height(20f)
			});
			if (flag)
			{
				Process.Start(Setting.HelpUrl + "/docx/SAeAda11zoNmuoxhS6ncMzVOnke");
			}
			GUILayout.FlexibleSpace();
			EditorGUILayout.EndHorizontal();
			GUITools.DrawSeparator(ScanSettingWindow.I.pageWidth - 20f);
			int num = (int)this.data.globalAssetsScanMode;
			EditorGUI.BeginChangeCheck();
			num = GUITools.ExecutePopupMethod("全局资源扫描模式[Global Scan Mode]: ", num, this.scanModeOptions, this.rect.width / 2f, 280f, false);
			bool flag2 = EditorGUI.EndChangeCheck();
			if (flag2)
			{
				this.data.globalAssetsScanMode = (GlobalConfig.e_Global_Assets_Scan_Mode)num;
			}
			GUITools.DrawColoredRectangle(this.rect.width);
			bool flag3 = this.targetConfigTreeView == null;
			if (flag3)
			{
				this.targetConfigTreeView = ScanAssetsConfigTreeView.Create("General-Target", "目标资源配置", false, null, null, 0, ref this.data.globalTargetConfigs, new GUIContent("目标资源", "可使用正则匹配"), "Assets");
				this.targetConfigTreeView.minConfigCountToggle = true;
				this.targetConfigTreeView.isLimitEnabled = false;
			}
			this.targetConfigTreeView.Draw();
			GUITools.DrawColoredRectangle(this.rect.width);
			bool flag4 = this.ignoreConfigTreeView == null;
			if (flag4)
			{
				this.ignoreConfigTreeView = ScanAssetsConfigTreeView.Create("General-Ignore", "忽略资源配置", false, null, null, 0, ref this.data.globalIgnoreConfigs, new GUIContent("忽略资源", "可使用正则匹配"), "Assets");
			}
			this.ignoreConfigTreeView.minConfigCountToggle = false;
			this.ignoreConfigTreeView.isLimitEnabled = false;
			this.ignoreConfigTreeView.Draw();
			GUITools.DrawColoredRectangle(this.rect.width);
			this.failedDataFolder = this.data.failedDataFolderPath;
			GUILayout.BeginHorizontal(new GUILayoutOption[0]);
			GUILayoutOption[] array = new GUILayoutOption[]
			{
				GUILayout.Width(500f)
			};
			GUILayout.Label("通过\"Run Selected Modules\"接口运行所包含的检测模块：", array);
			GUILayoutOption[] array2 = new GUILayoutOption[]
			{
				GUILayout.Width(500f)
			};
			GUILayout.Label("通过\"Fix Selected Modules\"接口运行所包含的修复模块：", array2);
			GUILayout.EndHorizontal();
			ToolsHelper.Pair<bool, bool> pair = GUITools.CreateControl("基本资源检测 [Basic Assets Check] ", "基本资源修复 [Basic Assets Fix]", 300, this.data.scanModules["Basic_Assets_Check"], this.data.fixModules["Basic_Assets_Fix"]);
			this.data.scanModules["Basic_Assets_Check"] = pair.GetItem1();
			this.data.fixModules["Basic_Assets_Fix"] = pair.GetItem2();
			pair = GUITools.CreateControl("场景检测 [Scenes Check] ", "场景修复 [Scenes Fix]", 300, this.data.scanModules["Scenes_Check"], this.data.fixModules["Scenes_Fix"]);
			this.data.scanModules["Scenes_Check"] = pair.GetItem1();
			this.data.fixModules["Scenes_Fix"] = pair.GetItem2();
			pair = GUITools.CreateControl("全局设置检测 [Global Settings Check] ", "全局设置修复 [Fix Global Settings]", 300, this.data.scanModules["Global_Settings_Check"], this.data.fixModules["Global_Settings_Fix"]);
			this.data.scanModules["Global_Settings_Check"] = pair.GetItem1();
			this.data.fixModules["Global_Settings_Fix"] = pair.GetItem2();
			this.data.scanModules["CS_Check"] = GUITools.DisplayGuiElement("C#代码检测 [CS Check] ", 300, this.data.scanModules["CS_Check"], true);
			this.data.scanModules["Custom_Rules_Check"] = GUITools.DisplayGuiElement("自定义规则检测 [Custom Rules Check] ", 300, this.data.scanModules["Custom_Rules_Check"], true);
			this.data.scanModules["Effects_Play_Check"] = GUITools.DisplayGuiElement("特效播放检测 [Effects Play Check] ", 300, this.data.scanModules["Effects_Play_Check"], true);
			this.data.scanModules["Shader_Analysis"] = GUITools.DisplayGuiElement("Shader分析 [Shaders Analysis] ", 300, this.data.scanModules["Shader_Analysis"], true);
			this.data.scanModules["Art_Assets_Check"] = GUITools.DisplayGuiElement("美术资源检测 [Art Assets Check] ", 300, this.data.scanModules["Art_Assets_Check"], true);
			EditorGUILayout.EndVertical();
		}

		// Token: 0x040009D8 RID: 2520
		private string projectScanConfigPath;

		// Token: 0x040009D9 RID: 2521
		private string locationPath;

		// Token: 0x040009DA RID: 2522
		private string[] scanModeOptions = new string[]
		{
			"All",
			"Target Only",
			"Target Only With Depends"
		};

		// Token: 0x040009DB RID: 2523
		private ScanAssetsConfigTreeView targetConfigTreeView;

		// Token: 0x040009DC RID: 2524
		private ScanAssetsConfigTreeView ignoreConfigTreeView;

		// Token: 0x040009DD RID: 2525
		private string failedDataFolder = "";
	}
}
